package br.com.dawj.action;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.dawj.modelo.Pessoa;

/**
 * Servlet implementation class SaudacaoAction
 */
@WebServlet("/SaudacaoAction")
public class SaudacaoAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
    public SaudacaoAction() {
        super();
        
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processoRequisicao(request, response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processoRequisicao(request, response);
	}
	
	public void processoRequisicao(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException{
		
		Pessoa pessoa = new Pessoa();
		
		pessoa.setNome(req.getParameter("nome"));
		pessoa.setSobrenome(req.getParameter("sobrenome"));
		
		req.setAttribute("pessoa", pessoa);
		
		RequestDispatcher view = req.getRequestDispatcher("saudacao.jsp");
		view.forward(req, resp);
	}
}
